#include <bits/stdc++.h>
using namespace std;
int t;
int n, m, l, V;
int d[100005];
int v[100005];
int a[100005];
int p[100005];
int vp[105][105];
bool A = 1, B = 1, C = 1;
int s;
int ans;
//int x;
bool op[105];
int sum;
bool bl[1005];
bool cs[10005];
int qh()
{
    int summ = 0;
    for (int i = 1;i <= m;i++)
    {
        //int sss = 0;
        if (op[i] == 1)
        {
            for (int j = 1;j <= n;j++)
            {
                if (p[i] >= d[j])
                {
                    if (vp[i][j] > V * V)
                    {
                        bl[j] = 1;
                    }
                }
            }
            //summ = max(summ, sss);
        }
    }
    for (int j = 1;j <= n;j++)
        summ += bl[j];
    for (int j = 1;j <= n;j++)
        bl[j] = 0;
    return summ;
}
void f(int x, int sum)
{
    if (x == m)
    {
        //cout<<qh()<<endl;
        if (s == qh())
        {
            ans = min(ans, sum);
        }
        return ;
    }
    op[x + 1] = 1;
    f(x + 1, sum + 1);
    op[x + 1] = 0;
    f(x + 1, sum);
    return ;
}
int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    scanf("%d", &t);
    while (t--)
    {
        //x = 0;
        s = 0;
        A = 1;
        B = 1;
        C = 1;
        ans = 0;
        scanf("%d%d%d%d", &n, &m, &l, &V);
        for (int i = 1;i <= n;i++)
        {
            scanf("%d%d%d", d + i, v + i, a + i);
            if (a[i] != 0)
                A = 0;
            if (a[i] <= 0)
                B = 0;
            if (a[i] >= 0)
                C = 0;
        }
        for (int i = 1;i <= m;i++)
            scanf("%d", p + i);
        if (A == 1)
        {

            for (int i = 1;i <= n;i++)
            {
                if (v[i] > V && d[i] <= p[m])
                {
                    s++;
                    //x = max(x, d[i]);
                }
                
            }
            if (s == 0)
                m++;
            printf("%d %d\n", s, m - 1);
        }
        else if (B == 1)
        {
            for (int i = 1;i <= n;i++)
            {
                if ((2 * a[i] * (l - d[i]) + v[i] * v[i]) > (V * V) && (((V * V - v[i] * v[i])) + d[i] * a[i] * 2) < (p[m] * a[i] * 2) && d[i] <= p[m])
                {
                    s++;
                    //x = max(x, int(ceil(1.0 * (V * V - v[i] * v[i]) / a[i] / 2.0 + d[i])));
                }
            }
            if (s == 0)
                m++;
            printf("%d %d\n", s, m - 1);
        }
        else
        {
            for (int i = 1;i <= m;i++)
            {
                //int ss = 0;
                for (int j = 1;j <= n;j++)
                {
                    if (p[i] >= d[j])
                    {
                        vp[i][j] = (p[i] - d[j]) * 2 * a[j] + v[j] * v[j];
                        if (vp[i][j] < 0)
                            vp[i][j] = 0;
                        if (vp[i][j] > V * V)
                        {
                            cs[j] = 1;
                        }
                    }
                }

                
            }
            /*for (int i = 1;i <= m;i++)
                cout<<vp[i][1]<<" ";*/
            for (int i = 1;i <= n;i++) 
            {
                //cout<<cs[i]<<" ";
                s += cs[i];
                cs[i] = 0;
            }
            ans = 1e9;
            f(0, 0);
            printf("%d %d\n", s, m - ans);
        }
    }
    
    return 0;
}